<#
 #   It is recommended to test the script on a local machine for its purpose and effects. 
 #   ManageEngine Endpoint Central will not be responsible for any 
 #   damage/loss to the data/setup based on the behavior of the script.

 #   Description: Script is designed to check whether the DNS configuration is set to static or dynamic for all network adapters.
 #   Configuration Type - COMPUTER
#>

# Get all network adapters
$adapters = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true }

foreach ($adapter in $adapters) {
    Write-Host "Adapter: $($adapter.Description)"

    # Check if DNS is set statically or dynamically
    if ($adapter.DNSServerSearchOrder -and $adapter.DNSServerSearchOrder.Count -gt 0) {
        Write-Host "DNS Servers (Static): $($adapter.DNSServerSearchOrder -join ', ')"
        Write-Host "Configuration: Static"
    } else {
        Write-Host "Configuration: Dynamic (DNS servers obtained via DHCP)"
    }

    Write-Host "----------------------------------------"
}